/**
 * Copyright(c) 2020 NESENSOR.
 * <p>
 * History:
 * 2019/9/12 0012 15:12 Created by Author_zero
 */
package com.funtl.spring.cloud.alibaba.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * TODO: Must write comments.
 *
 * @author <a href="mailto:Author_zero@nesensor.com">Author_zero</a>
 * @version 1.0 2019/9/12 0012 15:12
 */
@RestController
public class TestController {
    private final RestTemplate restTemplate;

    @Autowired
    public TestController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @GetMapping(value = "/echo/{str}")
    public String echo(@PathVariable String str) {
        // 使用服务名请求服务提供者
        return restTemplate.getForObject("http://service-provider/echo/" + str, String.class);
    }
}
